package com.feicheng.lanniao.service.impl;

import com.feicheng.lanniao.entity.HouseBuyClientVo;
import com.feicheng.lanniao.mapper.HouseBuyClientVoMapper;
import com.feicheng.lanniao.result.ResultInfo;
import com.feicheng.lanniao.service.IHouseBuyClientVoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.time.LocalDateTime;

import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * VIEW 服务实现类
 * </p>
 *
 * @author feichengTech
 * @since 2021-09-07
 */
@Service
public class HouseBuyClientVoServiceImpl extends ServiceImpl<HouseBuyClientVoMapper, HouseBuyClientVo> implements IHouseBuyClientVoService {

	//买房列表查询
	@Override
	public Page<HouseBuyClientVo> getlist(
			String title, 
			String detail,
			Integer  clientId , 
			Integer currentPage, 
			Integer pageSize
			) {
		Page<HouseBuyClientVo> p = new Page<HouseBuyClientVo>();
		p.setCurrent(currentPage); 
		p.setSize(pageSize);
		QueryWrapper<HouseBuyClientVo> queryWrapper = new QueryWrapper<HouseBuyClientVo>();
		if(StringUtils.hasLength(title)) {
			queryWrapper.like("title",title);							
		}
		if(StringUtils.hasLength(detail)) {
			queryWrapper.like("detail",detail);							
		}
		if(null != clientId) {
			queryWrapper.like("client_id", clientId);
		}
		Page<HouseBuyClientVo> page = this.page(p, queryWrapper);	
		return page;		
	}

	@Override
	public ResultInfo getInfo(Integer houseBuyId) {
		QueryWrapper<HouseBuyClientVo> queryWrapper = new QueryWrapper<HouseBuyClientVo>();
		queryWrapper.eq("house_buy_id", houseBuyId);
		return ResultInfo.success(this.getOne(queryWrapper));
	}
	
}
